import Vue from 'vue';
import VueRouter from 'vue-router';
import index from '../views/index.vue';
import login from '../views/login.vue';
import forgot from '../views/forgot.vue';
import register from '../views/register.vue';
Vue.use(VueRouter)

const routes = [
    // 主页
    {
        path: '/',
        name: 'index',
        component: index,
        meta: {
            index: 0,
            title: '首页'
        }
    },

    // 登录
    {
        path: '/login',
        name: 'login',
        component: login,
        meta: {
            index: 0,
            title: '登录'
        }
    },

            // 注册
        {
            path: '/register',
            name: 'register',
            component: register,
            meta: {
                index: 0,
                title: '注册'
            }
        },
    
    // 忘记密码
    {
        path: '/forgot',
        name: "forgot",
        component: forgot,
        meta: {
            index: 0,
            title: '忘记密码'
        }
    },

    // 修改密码
    {
        path: '/user/password',
        name: "password",
        component: () => import("../views/user/password.vue"),
        meta: {
            index: 0,
            title: '修改密码'
        }
    },

    // 视频播放页
    {
        path: "/media/video",
        name: "video",
        component: () => import('../views/media/video.vue'),
        meta: {
            index: 0,
            title: "视频"
        }
    },

    // 音频播放页
    {
        path: "/media/audio",
        name: "audio",
        component: () => import('../views/media/audio.vue'),
        meta: {
            index: 0,
            title: "音频"
        }
    },

    
    
    
    
                
        
            // 普通用户路由
        {
            path: '/regular_users/table',
            name: 'regular_users_table',
            component: () => import('../views/regular_users/table.vue'),
            meta: {
                index: 0,
                title: '普通用户列表'
            }
        },
        {
            path: '/regular_users/view',
            name: 'regular_users_view',
            component: () => import('../views/regular_users/view.vue'),
            meta: {
                index: 0,
                title: '普通用户详情'
            }
        },
            // 通知公告路由
        {
            path: '/notification_announcement/table',
            name: 'notification_announcement_table',
            component: () => import('../views/notification_announcement/table.vue'),
            meta: {
                index: 0,
                title: '通知公告列表'
            }
        },
        {
            path: '/notification_announcement/view',
            name: 'notification_announcement_view',
            component: () => import('../views/notification_announcement/view.vue'),
            meta: {
                index: 0,
                title: '通知公告详情'
            }
        },
            // 数据信息路由
        {
            path: '/data_information/table',
            name: 'data_information_table',
            component: () => import('../views/data_information/table.vue'),
            meta: {
                index: 0,
                title: '数据信息列表'
            }
        },
        {
            path: '/data_information/view',
            name: 'data_information_view',
            component: () => import('../views/data_information/view.vue'),
            meta: {
                index: 0,
                title: '数据信息详情'
            }
        },
            // 得分分析路由
        {
            path: '/score_analysis/table',
            name: 'score_analysis_table',
            component: () => import('../views/score_analysis/table.vue'),
            meta: {
                index: 0,
                title: '得分分析列表'
            }
        },
        {
            path: '/score_analysis/view',
            name: 'score_analysis_view',
            component: () => import('../views/score_analysis/view.vue'),
            meta: {
                index: 0,
                title: '得分分析详情'
            }
        },
            // 篮板分析路由
        {
            path: '/backboard_analysis/table',
            name: 'backboard_analysis_table',
            component: () => import('../views/backboard_analysis/table.vue'),
            meta: {
                index: 0,
                title: '篮板分析列表'
            }
        },
        {
            path: '/backboard_analysis/view',
            name: 'backboard_analysis_view',
            component: () => import('../views/backboard_analysis/view.vue'),
            meta: {
                index: 0,
                title: '篮板分析详情'
            }
        },
            // 助攻分析路由
        {
            path: '/assist_analysis/table',
            name: 'assist_analysis_table',
            component: () => import('../views/assist_analysis/table.vue'),
            meta: {
                index: 0,
                title: '助攻分析列表'
            }
        },
        {
            path: '/assist_analysis/view',
            name: 'assist_analysis_view',
            component: () => import('../views/assist_analysis/view.vue'),
            meta: {
                index: 0,
                title: '助攻分析详情'
            }
        },
            // 盖帽分析路由
        {
            path: '/cap_analysis/table',
            name: 'cap_analysis_table',
            component: () => import('../views/cap_analysis/table.vue'),
            meta: {
                index: 0,
                title: '盖帽分析列表'
            }
        },
        {
            path: '/cap_analysis/view',
            name: 'cap_analysis_view',
            component: () => import('../views/cap_analysis/view.vue'),
            meta: {
                index: 0,
                title: '盖帽分析详情'
            }
        },
            // 抢断分析路由
        {
            path: '/preemptive_analysis/table',
            name: 'preemptive_analysis_table',
            component: () => import('../views/preemptive_analysis/table.vue'),
            meta: {
                index: 0,
                title: '抢断分析列表'
            }
        },
        {
            path: '/preemptive_analysis/view',
            name: 'preemptive_analysis_view',
            component: () => import('../views/preemptive_analysis/view.vue'),
            meta: {
                index: 0,
                title: '抢断分析详情'
            }
        },
            // 球队三分分析路由
        {
            path: '/three_point_analysis_of_the_team/table',
            name: 'three_point_analysis_of_the_team_table',
            component: () => import('../views/three_point_analysis_of_the_team/table.vue'),
            meta: {
                index: 0,
                title: '球队三分分析列表'
            }
        },
        {
            path: '/three_point_analysis_of_the_team/view',
            name: 'three_point_analysis_of_the_team_view',
            component: () => import('../views/three_point_analysis_of_the_team/view.vue'),
            meta: {
                index: 0,
                title: '球队三分分析详情'
            }
        },
            // 球队两分分析路由
        {
            path: '/team_two_point_analysis/table',
            name: 'team_two_point_analysis_table',
            component: () => import('../views/team_two_point_analysis/table.vue'),
            meta: {
                index: 0,
                title: '球队两分分析列表'
            }
        },
        {
            path: '/team_two_point_analysis/view',
            name: 'team_two_point_analysis_view',
            component: () => import('../views/team_two_point_analysis/view.vue'),
            meta: {
                index: 0,
                title: '球队两分分析详情'
            }
        },
    
    // 用户路由
    {
        path: '/user/table',
        name: 'user_table',
        component: () => import('../views/user/table.vue'),
        meta: {
            index: 0,
            title: '用户列表'
        }
    },
    {
        path: '/user/view',
        name: 'user_view',
        component: () => import('../views/user/view.vue'),
        meta: {
            index: 0,
            title: '用户详情'
        }
    },
    {
        path: '/user/info',
        name: 'user_info',
        component: () => import('../views/user/info.vue'),
        meta: {
            index: 0,
            title: '个人信息'
        }
    },
    // 用户组路由
    {
        path: '/user_group/table',
        name: 'user_group_table',
        component: () => import('../views/user_group/table.vue'),
        meta: {
            index: 0,
            title: '用户组列表'
        }
    },
    {
        path: '/user_group/view',
        name: 'user_group_view',
        component: () => import('../views/user_group/view.vue'),
        meta: {
            index: 0,
            title: '用户组详情'
        }
    }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    let token = to.query.token;
    if (token) {
        $.db.set("token", token, 120);
    }
    next();
})

router.afterEach((to, from, next) => {
    let title = "NBA球员数据分析系统-admin";
    document.title = title;
})

export default router
